package org.kongqian;

import org.kongqian.interceptor.LoginInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@MapperScan("org.kongqian.*.mapper")
@EnableCaching
public class CarAppStart implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;
    public static void main(String[] args) {
        SpringApplication.run(CarAppStart.class, args);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                //拦截所有
                .addPathPatterns("/**")
                //放行
                .excludePathPatterns("/logininfo/**")
                .excludePathPatterns("/user/register/**")
                .excludePathPatterns("/user/bind/**")
                .excludePathPatterns("/verifyCode/**")
                .excludePathPatterns("/fastdfs");

    }
}
